﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericLibrariesToolKit;
using GenericLibrariesToolKit.Enumeration;
using Model;

namespace BLL.Users.Impl
{
    /// <summary>
    /// 专家业务接口实现
    /// </summary>
    public class ExpertBOImpl : DaoSupport<Expert> ,ExpertBO
    {
        public List<Expert> ShowTopExpert(int topNumber)
        {
            Dictionary<string, string> orderByDictionary=new Dictionary<string,string>();
            //添加排序条件及排序方式
            orderByDictionary.Add("ExpertClickAmount","desc");
            //执行查询
            QueryResult<Expert> expertQueryResult = GetScrollData(0, topNumber, orderByDictionary);
            //获取数据列表
            List<Expert> experts = expertQueryResult.ResultList;
            return experts;
        }

        public List<Expert> GetExpertByName(string expertName)
        {
            //设置where查询条件
            WhereCondition[] whereCondition = new WhereCondition[] 
            {
                 new WhereCondition(WhereJoinType.NULL,"ExpertFirstName",MatchType.EQUAL,expertName),
                 new WhereCondition(WhereJoinType.OR,"ExpertLastName",MatchType.EQUAL,expertName),
                 new WhereCondition(WhereJoinType.OR,"ExpertId",MatchType.EQUAL,expertName),
            };
            //执行查询
            QueryResult < Expert > expertSearchResult = GetScrollData(-1, -1, whereCondition);
            List < Expert > experts = expertSearchResult.ResultList;
            return experts;
        }
    }
}
